package com.chis.ms;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @Description
 * @Company zwx
 * @author wlj
 * @version 2019年06月19日
 */
public class ConversAof {
    public static void main(String[] args) throws Exception {
        File file1 = new File("C:\\Users\\Administrator\\Desktop\\1.txt");
        FileReader m = null;
        try {
            m = new FileReader(file1);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        BufferedReader reader = new BufferedReader(m);
        StringBuilder sb = new StringBuilder();
        FileWriter fileWriter = new FileWriter("C:\\Users\\Administrator\\Desktop\\2.txt");
        while (true) {
            String nextline = null;
            try {
                nextline = reader.readLine();
                if(nextline != null){
                    if(nextline.startsWith("*")){
                        System.out.println(sb.toString());
                        fileWriter.append(sb.toString()).append("\r\n");
                        sb = new StringBuilder();
                    } else {
                        if(!nextline.startsWith("$")){
                            sb.append(nextline).append(" ");
                        }
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (nextline == null) break;
        }
        System.out.println(sb.toString());
        fileWriter.append(sb.toString()).append("\r\n");
        fileWriter.close();
    }
}
